# -*- coding=utf-8 -*-
# @time:2021/8/9
# @phone:15874198829
# @author:码尚教育_星瑶
# 单点触控
import time

from appium.webdriver.common.touch_action import TouchAction
# 多点触控
from appium.webdriver.common.multi_action import MultiAction
from appium  import webdriver
from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
"""
MultiAction  多点触控
"""
desired_caps={
    "automationName":"UiAutomator2", #默认框架
    "platformName":"Android", #指定操作系统
"platformVersion":"7.1.2",#指定系统版本
    "deviceName":"127.0.0.1:62001",#指定设备名称
    "appPackage":"com.baidu.BaiduMap",#被操作的应用程序包名
    "appActivity":"com.baidu.baidumaps.MapsActivity" , #启动页面
    "noReset":True  #  为true 不重置  为false 重置
}
# 发送指令给appium server
driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
# 获取整个屏幕的大小
size=driver.get_window_size()
width=size["width"]
height=size["height"]




def change_big():
    # 模拟大拇指触屏操作
    action_1 = TouchAction(driver)
    action_1.press(x=width * 0.5, y=height * 0.5).wait(1000).move_to(x=width * 0.5, y=height * 0.8).wait(1000).release()
    # 模拟食指触屏操作
    action_2 = TouchAction(driver)
    action_2.press(x=width * 0.5, y=height * 0.4).move_to(x=width * 0.5, y=height * 0.1).release()
    # 两个触屏的操作同时进行
    manyactions = MultiAction(driver)
    print("开始放大====>")
    manyactions.add(action_1)
    manyactions.add(action_2)
    manyactions.perform()
    print("放大操作完成")


for i in range(0,6):
    change_big()
# 实现缩小的操作
# 运动轨迹不太一样



